<!DOCTYPE html>












  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">









  
  
    
  
  <link rel="stylesheet" media="all" href="https://cdnjs.cloudflare.com/ajax/libs/Han/3.3.0/han.min.css">




<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">



















  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






  

<link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=6.3.0" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=6.3.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=6.3.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=6.3.0">


  <link rel="mask-icon" href="/images/logo.svg?v=6.3.0" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '6.3.0',
    sidebar: {"position":"left","display":"hide","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="依赖示例12345678910111213141516&amp;lt;dependency&amp;gt;    &amp;lt;groupId&amp;gt;com.zaxxer&amp;lt;/groupId&amp;gt;    &amp;lt;artifactId&amp;gt;HikariCP&amp;lt;/artifactId&amp;gt;    &amp;lt;version&amp;gt;2.4.6&amp;lt;/version&amp;gt;    &amp;lt;type&amp;gt;jar&amp;l">
<meta name="keywords" content="maven">
<meta property="og:type" content="article">
<meta property="og:title" content="maven">
<meta property="og:url" content="http://codertang.com/2018/03/30/maven/index.html">
<meta property="og:site_name" content="Tonny&#39;s Blog">
<meta property="og:description" content="依赖示例12345678910111213141516&amp;lt;dependency&amp;gt;    &amp;lt;groupId&amp;gt;com.zaxxer&amp;lt;/groupId&amp;gt;    &amp;lt;artifactId&amp;gt;HikariCP&amp;lt;/artifactId&amp;gt;    &amp;lt;version&amp;gt;2.4.6&amp;lt;/version&amp;gt;    &amp;lt;type&amp;gt;jar&amp;l">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2021-02-25T09:25:48.217Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="maven">
<meta name="twitter:description" content="依赖示例12345678910111213141516&amp;lt;dependency&amp;gt;    &amp;lt;groupId&amp;gt;com.zaxxer&amp;lt;/groupId&amp;gt;    &amp;lt;artifactId&amp;gt;HikariCP&amp;lt;/artifactId&amp;gt;    &amp;lt;version&amp;gt;2.4.6&amp;lt;/version&amp;gt;    &amp;lt;type&amp;gt;jar&amp;l">






  <link rel="canonical" href="http://codertang.com/2018/03/30/maven/">



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>maven | Tonny's Blog</title>
  









  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Tonny's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <p class="site-subtitle">莫等闲, 白了少年头, 空悲切</p>
      
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">
    <a href="/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-categories">
    <a href="/categories/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>
  </li>

      
      
    </ul>
  

  
    

  

  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://codertang.com/2018/03/30/maven/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Tonny Yi">
      <meta itemprop="description" content="Coding, Life, Zen">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Tonny's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">maven
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2018-03-30 15:16:30" itemprop="dateCreated datePublished" datetime="2018-03-30T15:16:30+08:00">2018-03-30</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2021-02-25 17:25:48" itemprop="dateModified" datetime="2021-02-25T17:25:48+08:00">2021-02-25</time>
              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/maven/" itemprop="url" rel="index"><span itemprop="name">maven</span></a></span>

                
                
                  ，
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/maven/tools/" itemprop="url" rel="index"><span itemprop="name">tools</span></a></span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        <h2 id="依赖示例"><a href="#依赖示例" class="headerlink" title="依赖示例"></a>依赖示例</h2><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>com.zaxxer<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>HikariCP<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">version</span>&gt;</span>2.4.6<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">type</span>&gt;</span>jar<span class="tag">&lt;/<span class="name">type</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">scope</span>&gt;</span>compile<span class="tag">&lt;/<span class="name">scope</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">optional</span>&gt;</span>true<span class="tag">&lt;/<span class="name">optional</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">classifier</span>&gt;</span>jdk15<span class="tag">&lt;/<span class="name">classifier</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">systemPath</span>&gt;</span>$&#123;project.basedir&#125;/lib/my-jar.jar<span class="tag">&lt;/<span class="name">systemPath</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">exclusions</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">exclusion</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.slf4j<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>slf4j-api<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">exclusion</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">exclusions</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>
<a id="more"></a>
<h3 id="坐标"><a href="#坐标" class="headerlink" title="坐标"></a>坐标</h3><p>构件的唯一标识</p>
<ul>
<li><code>groupId</code> : 定义项目所属组, <strong>必选</strong></li>
<li><code>artifactId</code> : 定义项目在组内的唯一id, <strong>必选</strong></li>
<li><code>1.0.0-SNAPSHOT</code> : 版本号, <strong>必选</strong>, Spring: M1, M2, RC1, RC2, RELEASE</li>
</ul>
<p><strong>其他非必选属性</strong></p>
<ul>
<li><code>type</code> : 打包方式, 默认: <code>jar</code>, 可选值: <code>war</code>, <code>pom</code>, <code>ejb-client</code></li>
<li><code>scope</code>: 作用域, 默认: <code>compile</code>, 会影响依赖调解</li>
<li><code>optional</code>: 可选依赖, 默认:<code>false</code>, 比如: jdbc驱动实现mysql/Oracle, 依赖者根据需要手动添加</li>
<li><code>classifier</code> : 帮助输出辅助构件, jdk14/jdk15/javadoc/source, <strong>无法直接定义自己项目的classifier</strong></li>
<li><code>systemPath</code>: 指定jar在本地文件系统的位置, <strong>只能在<code>SYSTEM</code>作用域下使用</strong></li>
<li><code>exclusions</code>: 依赖排除, 只需要<code>groupId</code>+<code>artifactId</code></li>
</ul>
<h3 id="版本号"><a href="#版本号" class="headerlink" title="版本号"></a>版本号</h3><blockquote>
<p>&lt;主版本&gt;.&lt;次版本&gt;.&lt;增量版本&gt;</p>
</blockquote>
<p><strong>快照版</strong> : xxx-api-0.0.1-20180329.080444-1029.jar</p>
<ul>
<li><code>0.0.1</code>: <code>0.0.1-SNAPSHOT</code></li>
<li><code>20180329.080444</code>: 2018年3月29号 8点4分44秒推送到了仓库</li>
<li><code>1029</code>: 当前版本的第1029次快照</li>
</ul>
<h2 id="依赖"><a href="#依赖" class="headerlink" title="依赖"></a>依赖</h2><h3 id="依赖范围"><a href="#依赖范围" class="headerlink" title="依赖范围"></a>依赖范围</h3><p>依赖范围用于控制传传递性依赖和影响classpath. maven编译/测试/运行时使用不同classpath, 有三种: 编译/测试/运行时<br>scope可选值有: </p>
<ul>
<li><code>compile</code>: <strong>默认值</strong>, 编译 + 测试 + 运行时, 如: spring-core</li>
<li><code>provided</code>: 编译 + 测试, JDK或运行时容器已提供, 如: servlet-api</li>
<li><code>runtime</code>: 测试 + 运行时</li>
<li><code>test</code>: 测试, 用于测试代码编译与执行, 如: junit</li>
<li><code>system</code>: 同<code>provided</code>, 通过<code>systemPath</code>指定jar包的位置, 不通过Maven仓库解析, 往往与本机系统绑定. <strong>不推荐</strong></li>
<li><code>import</code>: 2.0.9版本后可用, <strong>对三种都不生效</strong>, 在依赖类型为pom时使用, 将依赖的<code>dependencyManagement</code>部分合并到当前项目中</li>
</ul>
<h3 id="传递性依赖"><a href="#传递性依赖" class="headerlink" title="传递性依赖"></a>传递性依赖</h3><p>A -&gt; B -&gt; C, 只需要显示的依赖A, B 和 C自动引入<br>A 对于 B 是第一直接依赖, B 对于 C 是第二直接依赖, A 对于 C 是传递性依赖<br>传递性依赖范围(scope)的确定:</p>
<table>
<thead>
<tr>
<th style="text-align:center"></th>
<th style="text-align:center">compile</th>
<th style="text-align:center">test</th>
<th style="text-align:center">provided</th>
<th style="text-align:center">runtime</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">compile</td>
<td style="text-align:center">compile</td>
<td style="text-align:center">-</td>
<td style="text-align:center">-</td>
<td style="text-align:center">runtime</td>
</tr>
<tr>
<td style="text-align:center">test</td>
<td style="text-align:center">test</td>
<td style="text-align:center">-</td>
<td style="text-align:center">-</td>
<td style="text-align:center">test</td>
</tr>
<tr>
<td style="text-align:center">provided</td>
<td style="text-align:center">provided</td>
<td style="text-align:center">-</td>
<td style="text-align:center">provided</td>
<td style="text-align:center">provided</td>
</tr>
<tr>
<td style="text-align:center">runtime</td>
<td style="text-align:center">runtime</td>
<td style="text-align:center">-</td>
<td style="text-align:center">-</td>
<td style="text-align:center">runtime</td>
</tr>
</tbody>
</table>
<p>第一列代表第一直接依赖, 第一行代表第二直接依赖, 中间为传递性依赖范围</p>
<h3 id="传递调解"><a href="#传递调解" class="headerlink" title="传递调解"></a>传递调解</h3><p><strong>原则: </strong></p>
<blockquote>
<ol>
<li>路径最短者优先</li>
<li>第一声明者优先</li>
</ol>
</blockquote>
<p>关于1:<br>a -&gt; c -&gt; d -&gt; M2.0<br>a -&gt; b -&gt; M1.0<br>最终 a -&gt; M1.0 </p>
<p>关于2:<br>a -&gt; c -&gt; M1.0<br>a -&gt; b -&gt; M2.0<br>最终 a -&gt; M1.0</p>
<h3 id="可选依赖"><a href="#可选依赖" class="headerlink" title="可选依赖"></a>可选依赖</h3><p>只对直接依赖生效, 间接依赖不传递.<br>A -&gt; B, B -&gt; X(optional), B -&gt; Y(optional), A值对B有依赖, 对X, Y没有依赖, 不管它们之间的依赖范围是怎样. A可以根据实际使用功能引入依赖. mysql/orcale</p>
<h3 id="排除依赖"><a href="#排除依赖" class="headerlink" title="排除依赖"></a>排除依赖</h3><p><code>&lt;exclusions&gt;</code>用于排除传递依赖(不管层级), 不需要version. 层级无关: a -&gt; b -&gt; c -&gt; d, 可在b依赖处exclusion掉d</p>
<h3 id="归类依赖"><a href="#归类依赖" class="headerlink" title="归类依赖"></a>归类依赖</h3><p>使用<code>&lt;properties&gt;</code>控制多个依赖版本, 便于维护</p>
<h3 id="依赖查看"><a href="#依赖查看" class="headerlink" title="依赖查看"></a>依赖查看</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mvn dependency:list     <span class="comment"># 列表, 坐标+依赖范围</span></span><br><span class="line">mvn dependency:tree     <span class="comment"># 依赖树</span></span><br><span class="line">mvn dependency:analyze</span><br></pre></td></tr></table></figure>
<p>结果有这几行: Used declared dependencies: 使用到但未显示声明; Unused declared dependencies: 未使用但显示声明的, 只分析编译主代码和测试代码用到的依赖, 运行时依赖发现不了. 需谨慎看待, 不要随便删.</p>
<h2 id="生命周期"><a href="#生命周期" class="headerlink" title="生命周期"></a><a href="https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference" target="_blank" rel="noopener">生命周期</a></h2><blockquote>
<p><code>mvn clean install</code> 到底干了什么, 怎么干的, 谁让他这么干的? </p>
</blockquote>
<p>maven之前项目构建的生命周期就已存在(清理/编译/测试/部署等), maven对其进行了抽象, 生命周期的实际行为全都有插件来完成.  每个生命周期包含一定的阶段(phase), 阶段间是有顺序的, 后面的阶段依赖于前面的阶段(调用一个阶段时会先执行其前面的阶段). 但生命周期之间是独立, 不互相依赖, 所以你执行clean时, 不会执行default生命周期. 定义: <code>${M2_HOME}/lib/maven-core-xx.jar/META-INF/plexus/components.xml</code></p>
<h3 id="clean生命"><a href="#clean生命" class="headerlink" title="clean生命"></a>clean生命</h3><p>其目的是清理项目, 包含三个阶段: </p>
<ul>
<li><code>pre-clean</code>: 执行清理前的工作</li>
<li><code>clean</code>: 清理上一次构建生成的文件</li>
<li><code>post-clean</code>: 执行清理后的工作</li>
</ul>
<h3 id="default生命周期"><a href="#default生命周期" class="headerlink" title="default生命周期"></a>default生命周期</h3><p>目的是构建项目, 包含的的阶段:</p>
<ul>
<li><code>validate</code></li>
<li><code>initialize</code></li>
<li><code>generate-sources</code></li>
<li><code>process-sources</code>: 对src/main/resources目录的内容进行变量替换等操作, 复制到项目输出的主classpath中</li>
<li><code>generate-resources</code></li>
<li><code>process-resources</code></li>
<li><code>compile</code>: 编译项目主源码, src/main/java</li>
<li><code>process-classes</code></li>
<li><code>generate-test-sources</code></li>
<li><code>process-test-sources</code>: 处理测试资源文件, src/test/resources</li>
<li><code>generate-test-resources</code></li>
<li><code>process-test-resources</code></li>
<li><code>test-compile</code>: 编译测试代码, src/test/java</li>
<li><code>process-test-classes</code></li>
<li><code>test</code>: 单元测试, 测试代码不会打包或部署</li>
<li><code>prepare-package</code></li>
<li><code>package</code>: 打包, jar/war</li>
<li><code>pre-integration-test</code></li>
<li><code>integration-test</code></li>
<li><code>post-integration-test</code></li>
<li><code>verify</code></li>
<li><code>install</code>: 安装到本地仓库</li>
<li><code>deploy</code>: 部署包到远程仓库</li>
</ul>
<h3 id="site生命周期"><a href="#site生命周期" class="headerlink" title="site生命周期"></a>site生命周期</h3><p>目的为建立项目站点, 包含的阶段: </p>
<ul>
<li><code>pre-site</code></li>
<li><code>site</code>: 生成项目站点文档</li>
<li><code>post-site</code>:</li>
<li><code>site-deploy</code>: 发布项目站点文档到服务器</li>
</ul>
<h3 id="命令行与生命周期关系"><a href="#命令行与生命周期关系" class="headerlink" title="命令行与生命周期关系"></a>命令行与生命周期关系</h3><ul>
<li><code>mvn clean</code>: 执行clean生命周期的<code>pre-clean</code>和<code>clean</code>阶段</li>
<li><code>mvn test</code>: 执行default生命周期从<code>validate</code>到<code>test</code>之间的所有阶段</li>
<li><code>mvn clean install</code>: 执行clean生命周期的<code>pre-clean</code>和<code>clean</code> + default生命周期的从<code>validate</code>到<code>isntall</code>的所有阶段.</li>
<li><code>mvn clean deploy site-deploy</code>: 执行clean生命周期的<code>pre-clean</code>和<code>clean</code> + default生命周期的的所有阶段 + site生命周期的所有阶段</li>
</ul>
<h2 id="插件"><a href="#插件" class="headerlink" title="插件"></a><a href="https://maven.apache.org/plugins/index.html" target="_blank" rel="noopener">插件</a></h2><h3 id="插件目标-goal"><a href="#插件目标-goal" class="headerlink" title="插件目标(goal)"></a>插件目标(goal)</h3><p>Maven核心只定义了抽象的生命周期, 具体的任务交由插件去完成.<br>每个插件可以实现多个功能, 每个功能就是一插件目标. <code>dependency:list</code>, <code>dependency:tree</code>冒号前是插件前缀, 冒号后是该插件的目标.<br>生命周期的阶段与插件的目标相互绑定. 如: default生命周期的compile阶段与maven-compile-plugin插件的compile目标. </p>
<p><strong>如果生命周期的阶段没有与任何插件的目标绑定, 则该阶段啥也会干</strong></p>
<h4 id="内置绑定"><a href="#内置绑定" class="headerlink" title="内置绑定"></a><a href="https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Built-in_Lifecycle_Bindings" target="_blank" rel="noopener">内置绑定</a></h4><p>绑定关系定义(版本3以后才有): <code>${M2_HOME}/lib/maven-core-xx.jar/META-INF/plexus/default-binding.xml</code></p>
<p><strong>clean生命周期阶段与插件目标绑定关系</strong></p>
<table>
<thead>
<tr>
<th style="text-align:center">生命周期阶段</th>
<th style="text-align:center">插件目标</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">pre-clean</td>
<td style="text-align:center">-</td>
</tr>
<tr>
<td style="text-align:center">clean</td>
<td style="text-align:center">maven-clean-plugin:clean</td>
</tr>
<tr>
<td style="text-align:center">post-clean</td>
<td style="text-align:center">-</td>
</tr>
</tbody>
</table>
<p><strong>default生命周期阶段与插件目标绑定关系</strong> </p>
<blockquote>
<ol>
<li>项目的打包类型(jar/war/pom/ear/maven-plugin)不同, 绑定关系有所区别</li>
<li>default生命周期还有许多其他阶段, 默认没有绑定任何插件, 因此也没有任何实际行为</li>
</ol>
</blockquote>
<table>
<thead>
<tr>
<th style="text-align:center">生命周期阶段</th>
<th style="text-align:center">插件目标</th>
<th style="text-align:center">执行任务</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">process-resources</td>
<td style="text-align:center">maven-resource-plugin:resources</td>
<td style="text-align:center">复制主资源文件到主输出目录</td>
</tr>
<tr>
<td style="text-align:center">compile</td>
<td style="text-align:center">maven-compiler-plugin:compile</td>
<td style="text-align:center">编译主代码到主输出目录</td>
</tr>
<tr>
<td style="text-align:center">process-test-resources</td>
<td style="text-align:center">maven-resources-plugin:testResources</td>
<td style="text-align:center">复制测试资源文件到测试输出目录</td>
</tr>
<tr>
<td style="text-align:center">test-compile</td>
<td style="text-align:center">maven-compile-plugin:testCompile</td>
<td style="text-align:center">编译测试代码到测试数据目录</td>
</tr>
<tr>
<td style="text-align:center">test</td>
<td style="text-align:center">maven-surefire-plugin:test</td>
<td style="text-align:center">执行测试用例</td>
</tr>
<tr>
<td style="text-align:center">package</td>
<td style="text-align:center">maven-jar-plugin:jar</td>
<td style="text-align:center">创建项目jar等</td>
</tr>
<tr>
<td style="text-align:center">install</td>
<td style="text-align:center">maven-install-plugin:install</td>
<td style="text-align:center">部署构建到本地仓库</td>
</tr>
<tr>
<td style="text-align:center">deploy</td>
<td style="text-align:center">maven-deploy-plugin:deploy</td>
<td style="text-align:center">部署构件到远程仓库</td>
</tr>
</tbody>
</table>
<p><strong>site生命周期阶段与插件目标绑定关系</strong></p>
<table>
<thead>
<tr>
<th style="text-align:center">生命周期阶段</th>
<th style="text-align:center">插件目标</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">pre-site</td>
<td style="text-align:center">-</td>
</tr>
<tr>
<td style="text-align:center">site</td>
<td style="text-align:center">maven-site-plugin:site</td>
</tr>
<tr>
<td style="text-align:center">post-site</td>
<td style="text-align:center">-</td>
</tr>
<tr>
<td style="text-align:center">site-deploy</td>
<td style="text-align:center">maven-site-plugin:deploy</td>
</tr>
</tbody>
</table>
<h4 id="自定义绑定"><a href="#自定义绑定" class="headerlink" title="自定义绑定"></a>自定义绑定</h4><p>首先查询插件详细信息, 关注目标默认绑定的生命周期阶段(Bound to phase)<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">mvn <span class="built_in">help</span>:describe -Dplugin=org.apache.maven.plugins:maven-source-plugin:3.0.1 -Ddetail</span><br><span class="line">mvn <span class="built_in">help</span>:describe -Dplugin=<span class="built_in">source</span> -Ddetail  <span class="comment"># 简略写法</span></span><br></pre></td></tr></table></figure></p>
<p>输出<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">...</span><br><span class="line">source:jar</span><br><span class="line">   Description: This plugin bundles all the sources into a jar archive.</span><br><span class="line">   Implementation: org.apache.maven.plugins.source.SourceJarMojo</span><br><span class="line">   Language: java</span><br><span class="line">   Bound to phase: package</span><br><span class="line">   Before this mojo executes, it will call:</span><br><span class="line">    Phase: &apos;generate-sources&apos;</span><br><span class="line">...</span><br></pre></td></tr></table></figure></p>
<p>示例: 生成源码jar包<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">build</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">plugins</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-source-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">version</span>&gt;</span>3.0.0<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">executions</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">execution</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">id</span>&gt;</span>attach-sources<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">phase</span>&gt;</span>verify<span class="tag">&lt;/<span class="name">phase</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">goals</span>&gt;</span></span><br><span class="line">                        <span class="tag">&lt;<span class="name">goal</span>&gt;</span>jar<span class="tag">&lt;/<span class="name">goal</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;/<span class="name">goals</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;/<span class="name">execution</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">executions</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">attach</span>&gt;</span>true<span class="tag">&lt;/<span class="name">attach</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">plugins</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">build</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<h3 id="插件配置"><a href="#插件配置" class="headerlink" title="插件配置"></a>插件配置</h3><h4 id="命令行中使用"><a href="#命令行中使用" class="headerlink" title="命令行中使用"></a>命令行中使用</h4><p>命令行时使用<code>-D</code>参数(这是java自带的, 通过-D设置java系统属性):<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">mvn install -DskipTests     <span class="comment"># 编译不执行</span></span><br><span class="line">mvn install -Dmaven.test.skip=<span class="literal">true</span>  <span class="comment"># 不编译不执行</span></span><br></pre></td></tr></table></figure></p>
<h4 id="pom中全局配置"><a href="#pom中全局配置" class="headerlink" title="pom中全局配置"></a>pom中全局配置</h4><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-compiler-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">version</span>&gt;</span>3.1<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">source</span>&gt;</span>$&#123;java.src.version&#125;<span class="tag">&lt;/<span class="name">source</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">target</span>&gt;</span>$&#123;java.target.version&#125;<span class="tag">&lt;/<span class="name">target</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">encoding</span>&gt;</span>$&#123;project.encoding&#125;<span class="tag">&lt;/<span class="name">encoding</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h4 id="pom中插件任务配置"><a href="#pom中插件任务配置" class="headerlink" title="pom中插件任务配置"></a>pom中插件任务配置</h4><p>注意configuration的位置<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-antrun-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">executions</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">execution</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">id</span>&gt;</span>ant-validate<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">phase</span>&gt;</span>validate<span class="tag">&lt;/<span class="name">phase</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">goals</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">goal</span>&gt;</span>run<span class="tag">&lt;/<span class="name">goal</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">goals</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">tasks</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">echo</span>&gt;</span>Ant run bound to validate phase.<span class="tag">&lt;/<span class="name">echo</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;/<span class="name">tasks</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">execution</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">executions</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<h3 id="插件解析"><a href="#插件解析" class="headerlink" title="插件解析"></a>插件解析</h3><p>通过命令行执行插件目标:<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:tree</span><br><span class="line">mvn dependency:tree     <span class="comment"># 使用目标前缀执行插件目标</span></span><br></pre></td></tr></table></figure></p>
<h4 id="目标前缀解析"><a href="#目标前缀解析" class="headerlink" title="目标前缀解析"></a><a href="https://maven.apache.org/guides/introduction/introduction-to-plugin-prefix-mapping.html" target="_blank" rel="noopener">目标前缀解析</a></h4><p>执行<code>mvn dependency:tree</code>时, maven如如何选择对应的插件的?<br>如果插件的artifactId符合<code>maven-${prefix}-plugin</code>(官方插件格式, 自己别用) 或者 <code>${prefix}-maven-plugin</code>格式, maven会自动映射prefix到这个插件上.</p>
<p>查找流程:</p>
<ol>
<li>下载远程插件仓库的<code>maven-metadata.xml</code>文件, 重命名为<code>maven-metadata-${repoId}.xml</code>, 放到${groupId}路径下</li>
<li>将该路径下的<code>maven-metadata-local.xml</code>文件(如果有的话)和<code>maven-metadata-${repoId}.xml</code>文件合并</li>
<li>从合并后的内容中尝试解析出前缀对应的插件, 如果没找到则回到第一步, 查找下一个插件组.<br><code>~/.m2/repository/org/apache/maven/plugins/maven-metadata-&lt;仓库ID&gt;.xml</code> 和 <code>/~/.m2/repository/org/codehaus/mojo/maven-metadata-&lt;仓库ID&gt;.xml</code><br>配合<code>setting.xml</code>中<code>pluginGroups</code>配置</li>
</ol>
<blockquote>
<p>pluginGroups内的配置其用处就是在命令行使用某个插件但未指定groupId时搜索对应的插件</p>
</blockquote>
<h2 id="仓库"><a href="#仓库" class="headerlink" title="仓库"></a>仓库</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">Maven仓库</span><br><span class="line">    - 本地仓库(~/.m2/repository)</span><br><span class="line">    - 远程仓库</span><br><span class="line">        - 中央仓库</span><br><span class="line">        - 其他公共库</span><br><span class="line">        - 私服Nexus</span><br></pre></td></tr></table></figure>
<p>中央仓库的定义在超级POM中(<code>${M2_HOME}/lib/maven-model-builder-xx.jar/org/apache/maven/model/pom-4.0.0.xml</code>), 所有项目都会继承它.</p>
<p>进入本地仓库方式:</p>
<ol>
<li>从远程仓库拉取</li>
<li><code>mvn install:install-file -Dfile=./xxx -DgroupId=com.xxx -DartifactId=xxx -Dversion=xxx -Dpackaging=jar</code></li>
</ol>
<p>远程仓库:<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">repositories</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">repository</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">id</span>&gt;</span>xxx-xxxxx-releases<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>Repository for releases artifacts<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">url</span>&gt;</span>http://pixel.xxxxx.com/repository/group-releases<span class="tag">&lt;/<span class="name">url</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">snapshots</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">enabled</span>&gt;</span>false<span class="tag">&lt;/<span class="name">enabled</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">snapshots</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">releases</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">enabled</span>&gt;</span>true<span class="tag">&lt;/<span class="name">enabled</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">updatePolicy</span>&gt;</span>interval:60<span class="tag">&lt;/<span class="name">updatePolicy</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">releases</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">repository</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">repositories</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<p>几个子元素的说明:</p>
<ul>
<li><code>enabled</code>: 是否允许发布/快照版本下载</li>
<li><code>updatePolicy</code>: 从远程仓库更新的频率, 默认: Daily</li>
<li><code>checksumPolicy</code>: 校验文件策略, 上传构件时会同时上传校验文件. 下载时maven集合校验文件来验证构件, 校验失败后依据该配置执行操作. 默认: warn, 还有fail/ignore</li>
</ul>
<h3 id="远程仓库认证"><a href="#远程仓库认证" class="headerlink" title="远程仓库认证"></a>远程仓库认证</h3><p><strong><code>id</code>必须与<code>repository</code>中的id一致</strong><br><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">servers</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">server</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">id</span>&gt;</span>xxxxx.repo<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">username</span>&gt;</span>fw-deploy<span class="tag">&lt;/<span class="name">username</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">password</span>&gt;</span>example<span class="tag">&lt;/<span class="name">password</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">server</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">servers</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<h3 id="从仓库解析依赖流程"><a href="#从仓库解析依赖流程" class="headerlink" title="从仓库解析依赖流程"></a>从仓库解析依赖流程</h3><ol>
<li>如果依赖范围是<code>system</code>, 直接从本地文件系统解析构件</li>
<li>根据依赖坐标计算仓库路径, 尝试直接从本地仓库寻找构件</li>
<li>当本地仓库不存在构件, 且依赖的是正式版本, 则从遍历所有远程仓库, 发现后下载</li>
<li>如果依赖版本的是RELEASE或LATEST, 则基于更新策略读取所有远程仓库的元数据(groupId/artifactId/maven-metadata.xml), 并重命名为<code>maven-metadata-&lt;RepositoryID&gt;.xml</code>, 与本地仓库对应的元数据(如果有的话)合并后(maven-metadata-local.xml), 计算真实值</li>
<li>如果依赖的是SNAPSHOT逻辑同上</li>
<li>如果解析到的构件版本是时间戳格式, 则将其复制为非时间戳格式(如: SNAPSHOT), 并使用该非时间戳版本</li>
</ol>
<h3 id="install"><a href="#install" class="headerlink" title="install"></a>install</h3><ol>
<li>install时1.0.0-SNAPSHOT/下生成maven-metadata-local.xml</li>
<li>从远程仓库拉取maven-metadata.xml, 命名为”maven-metadata-\<repositoryid>.xml”，并保存到本地仓库相应目录</repositoryid></li>
<li>比较lastUpdated字段, 如果本地文件中的值较大, 则使用本地仓库中的jar, 否则下载远程仓库的<code>xxx-api-0.0.1-20180329.080444-1029.jar</code>到本地, 然后复制并重命名为<code>xxx-api-0.0.1-SNAPSHOT.jar</code>, 把原来的jar覆盖掉</li>
</ol>
<h2 id="超级pom"><a href="#超级pom" class="headerlink" title="超级pom"></a><a href="http://maven.apache.org/ref/3.0.4/maven-model-builder/super-pom.html" target="_blank" rel="noopener">超级pom</a></h2><p>文件<code>${M2_HOME}/lib/maven-model-builder-xx.jar/org/apache/maven/model/pom-4.0.0.xml</code>是所有maven项目都会默认继承它, 类似Java里的Object类.</p>
<h3 id="标准目录结构"><a href="#标准目录结构" class="headerlink" title="标准目录结构"></a>标准目录结构</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">src</span><br><span class="line">    main</span><br><span class="line">    java</span><br><span class="line">    resources</span><br><span class="line">    webapp</span><br><span class="line">        WEB-INF</span><br><span class="line">        web.xml</span><br><span class="line">    test</span><br><span class="line">        java</span><br><span class="line">        resources </span><br><span class="line">target</span><br><span class="line">    classes</span><br><span class="line">    generated-sources</span><br><span class="line">    generated-test-sources</span><br><span class="line">    &#123;build-filename&#125;</span><br><span class="line">    test-classes</span><br><span class="line">pom.xml</span><br></pre></td></tr></table></figure>
<h3 id="archetype生成项目骨架"><a href="#archetype生成项目骨架" class="headerlink" title="archetype生成项目骨架"></a>archetype生成项目骨架</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">mvn archetype:generate</span><br><span class="line">mvn groupId:artifactId:version:goal</span><br></pre></td></tr></table></figure>
<p>maven3默认使用jdk1.5编译</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">properties</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;<span class="name">maven.compiler.source</span>&gt;</span>1.8<span class="tag">&lt;/<span class="name">maven.compiler.source</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;<span class="name">maven.compiler.target</span>&gt;</span>1.8<span class="tag">&lt;/<span class="name">maven.compiler.target</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">properties</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-compiler-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">version</span>&gt;</span>(whatever version is current)<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">        <span class="comment">&lt;!-- or whatever version you use --&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">source</span>&gt;</span>1.7<span class="tag">&lt;/<span class="name">source</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">target</span>&gt;</span>1.7<span class="tag">&lt;/<span class="name">target</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h3 id="聚合与继承"><a href="#聚合与继承" class="headerlink" title="聚合与继承"></a>聚合与继承</h3><p>通常一起使用</p>
<blockquote>
<p><strong>聚合是为了快速方便的构建项目, 继承是为了消除重复配置.</strong><br>对于聚合模块来说, 它知道有哪些被聚合的模块, 但那些被聚合的模块不知道该模块的存在.<br>对于继承关系的父POM来说, 它不知道有哪些模块继承于它, 但那些子模块都必须知道自己的父POM是什么.</p>
</blockquote>
<p>聚合模块</p>
<ul>
<li>packaging: pom</li>
<li>一般位于顶层</li>
</ul>
<p>模块</p>
<ul>
<li>一般作为子目录</li>
<li>parent内的groupId/artifactId/version是必须的, relativePath默认值为../pom.xml</li>
</ul>
<h4 id="可继承的pom元素"><a href="#可继承的pom元素" class="headerlink" title="可继承的pom元素"></a>可继承的pom元素</h4><ul>
<li><strong>groupId</strong> : 组织id</li>
<li><strong>version</strong> : 版本号</li>
<li><strong>description</strong> : 项目描述</li>
<li><strong>organization</strong> : 项目所属组织信息</li>
<li><strong>inceptionYear</strong> : 项目创始年份</li>
<li><strong>url</strong> : 项目URL</li>
<li><strong>developers</strong> : 开发者列表 </li>
<li><strong>contributors</strong> : 贡献者列表</li>
<li><strong>distributionManagement</strong> : 部署配置 </li>
<li><strong>issueManagement</strong> : 缺陷跟踪系统信息</li>
<li><strong>ciManagerment</strong> : 持续集成配置</li>
<li><strong>scm</strong> : 版本控制信息</li>
<li><strong>mailingLists</strong> : 邮件列表</li>
<li><strong>propertes</strong> : 属性列表</li>
<li><strong>dependencies</strong> : 依赖列表</li>
<li><strong>dependencyManagement</strong> : 依赖管理配置 </li>
<li><strong>repositories</strong> : 仓库配置</li>
<li><strong>build</strong> : 源码目录配置, 输出目录配置, 插件配置, 插件管理配置等</li>
<li><strong>reporting</strong>: 项目报告输出目录, 报告插件配置等</li>
</ul>
<h4 id="dependencyManagement"><a href="#dependencyManagement" class="headerlink" title="dependencyManagement"></a>dependencyManagement</h4><p>不会引入实际的依赖, 但会约束dependencies下的依赖使用. 可以省去version/scope配置. 省去的配置不多, 但推荐用, 而且要放到父POM中.<br><strong>import</strong>依赖范围的作用: 将目标POM中的dependencyManagement配置导入并合并到当前POM的dependencyManagement元素中. 一般都指向的打包类型为POM的模块</p>
<h3 id="Maven属性"><a href="#Maven属性" class="headerlink" title="Maven属性"></a>Maven属性</h3><ol>
<li>内置属性</li>
</ol>
<ul>
<li><code>${basedir}</code> : 项目根目录, 即包含pom.xml的目录</li>
<li><code>${version}</code> : 项目版本</li>
</ul>
<ol start="2">
<li>POM属性<br>用户可以使用该类型的属性引用POM文件对应元素的值. 如<code>${project.artifactId}</code>就对应了<code>&lt;project&gt;</code>节点下<code>&lt;artifactId&gt;</code>节点的值. 常用POM属性包括: </li>
</ol>
<ul>
<li><code>${project.build.sourceDirectory}</code> : 项目主源码目录, 默认: <code>src/main/java</code></li>
<li><code>${project.build.testSourceDirectory}</code> : 项目测试代码目录, 默认: <code>src/test/java</code></li>
<li><code>${project.build.directory}</code> : 项目构建输出目录, 默认: <code>target/</code></li>
<li><code>${project.outputDirectory}</code> : 项目主代码编译输出目录, 默认: <code>target/classes/</code></li>
<li><code>${project.testOutputDirectory}</code> : 项目测试代码输出目录, 默认: <code>target/test-classes</code></li>
<li><code>${project.groupId}</code> : 项目的groupId</li>
<li><code>${project.artifactId}</code> : 项目的artifactId</li>
<li><code>${project.version}</code> : 项目的版本, 等同于 <code>${version}</code></li>
<li><code>${project.build.finalName}</code> : 项目打包输出文件名称, 默认: <code>${project.artifact}-${project.version}</code></li>
</ul>
<ol start="3">
<li><p>自定义属性<br><code>&lt;properties&gt;</code>节点下的定义的属性</p>
</li>
<li><p>settings属性<br>与POM属性类似, 不过引用的Settings.xml中的元素值. 以<code>settings</code>开头, 如: <code>${settings.localRepository}</code></p>
</li>
<li><p>Java系统属性<br>引用Java系统属性, 比如<code>${user.home}</code>指向了用户目录. 可以使用<code>mvn help:system</code></p>
</li>
<li><p>环境变量属性<br>以<code>env.</code>开头, 如: <code>${env.JAVA_HOME}</code>, 可以使用<code>mvn help:system</code></p>
</li>
</ol>
<h3 id="setting-xml"><a href="#setting-xml" class="headerlink" title="setting.xml"></a><a href="https://maven.apache.org/settings.html" target="_blank" rel="noopener">setting.xml</a></h3><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">settings</span> <span class="attr">xmlns</span>=<span class="string">"http://maven.apache.org/SETTINGS/1.0.0"</span> <span class="attr">xmlns:xsi</span>=<span class="string">"http://www.w3.org/2001/XMLSchema-instance"</span> <span class="attr">xsi:schemaLocation</span>=<span class="string">"http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">localRepository</span>&gt;</span>/Users/tonnyyi/workspace/MavenRepository<span class="tag">&lt;/<span class="name">localRepository</span>&gt;</span></span><br><span class="line">    </span><br><span class="line">    <span class="tag">&lt;<span class="name">mirrors</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">mirror</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">id</span>&gt;</span>nexus-aliyun<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">mirrorOf</span>&gt;</span>central<span class="tag">&lt;/<span class="name">mirrorOf</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">name</span>&gt;</span>Nexus aliyun<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">url</span>&gt;</span>http://maven.aliyun.com/nexus/content/groups/public<span class="tag">&lt;/<span class="name">url</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">mirror</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">mirrors</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">profiles</span>&gt;</span></span><br><span class="line">        <span class="comment">&lt;!-- 项目默认的编译级别为1.8 --&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">profile</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">id</span>&gt;</span>jdk-1.8<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">activation</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">jdk</span>&gt;</span>1.8<span class="tag">&lt;/<span class="name">jdk</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">activation</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">properties</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">maven.compiler.source</span>&gt;</span>1.8<span class="tag">&lt;/<span class="name">maven.compiler.source</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">maven.compiler.target</span>&gt;</span>1.8<span class="tag">&lt;/<span class="name">maven.compiler.target</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">maven.compiler.compilerVersion</span>&gt;</span>1.8<span class="tag">&lt;/<span class="name">maven.compiler.compilerVersion</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">properties</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">profile</span>&gt;</span></span><br><span class="line"></span><br><span class="line">        <span class="tag">&lt;<span class="name">profile</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">id</span>&gt;</span>aliyunRep<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">activation</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">jdk</span>&gt;</span>1.8<span class="tag">&lt;/<span class="name">jdk</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">activation</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">repositories</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">repository</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">id</span>&gt;</span>aliyunRep<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">name</span>&gt;</span>Aliyun Maven Respository<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">url</span>&gt;</span>http://maven.aliyun.com/nexus/content/groups/public/<span class="tag">&lt;/<span class="name">url</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">releases</span>&gt;</span></span><br><span class="line">                        <span class="tag">&lt;<span class="name">enabled</span>&gt;</span>true<span class="tag">&lt;/<span class="name">enabled</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;/<span class="name">releases</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">snapshots</span>&gt;</span></span><br><span class="line">                        <span class="tag">&lt;<span class="name">enabled</span>&gt;</span>false<span class="tag">&lt;/<span class="name">enabled</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;/<span class="name">snapshots</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;/<span class="name">repository</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">repositories</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">pluginRepositories</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">pluginRepository</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">id</span>&gt;</span>aliyunRep<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">name</span>&gt;</span>Aliyun Maven Respository<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">url</span>&gt;</span>http://maven.aliyun.com/nexus/content/groups/public/<span class="tag">&lt;/<span class="name">url</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">releases</span>&gt;</span></span><br><span class="line">                        <span class="tag">&lt;<span class="name">enabled</span>&gt;</span>true<span class="tag">&lt;/<span class="name">enabled</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;/<span class="name">releases</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">snapshots</span>&gt;</span></span><br><span class="line">                        <span class="tag">&lt;<span class="name">enabled</span>&gt;</span>false<span class="tag">&lt;/<span class="name">enabled</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;/<span class="name">snapshots</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;/<span class="name">pluginRepository</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">pluginRepositories</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">profile</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">profiles</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">pluginGroups</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">pluginGroup</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">pluginGroup</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">pluginGroup</span>&gt;</span>org.unidal.maven.plugins<span class="tag">&lt;/<span class="name">pluginGroup</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">pluginGroup</span>&gt;</span>org.jvnet.hudson.tools<span class="tag">&lt;/<span class="name">pluginGroup</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">pluginGroups</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">servers</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">server</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">httpConfiguration</span>&gt;</span></span><br><span class="line">                  <span class="tag">&lt;<span class="name">all</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">connectionTimeout</span>&gt;</span>5000<span class="tag">&lt;/<span class="name">connectionTimeout</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">readTimeout</span>&gt;</span>10000<span class="tag">&lt;/<span class="name">readTimeout</span>&gt;</span></span><br><span class="line">                  <span class="tag">&lt;/<span class="name">all</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;/<span class="name">httpConfiguration</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">server</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">servers</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">activeProfiles</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">activeProfile</span>&gt;</span>jdk-1.8<span class="tag">&lt;/<span class="name">activeProfile</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">activeProfile</span>&gt;</span>aliyunRep<span class="tag">&lt;/<span class="name">activeProfile</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">activeProfiles</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">settings</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h4 id="超级pom-1"><a href="#超级pom-1" class="headerlink" title="超级pom"></a>超级pom</h4><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">project</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">modelVersion</span>&gt;</span>4.0.0<span class="tag">&lt;/<span class="name">modelVersion</span>&gt;</span></span><br><span class="line"></span><br><span class="line">  <span class="tag">&lt;<span class="name">repositories</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">repository</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">id</span>&gt;</span>central<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">name</span>&gt;</span>Central Repository<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">url</span>&gt;</span>https://repo.maven.apache.org/maven2<span class="tag">&lt;/<span class="name">url</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">layout</span>&gt;</span>default<span class="tag">&lt;/<span class="name">layout</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">snapshots</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">enabled</span>&gt;</span>false<span class="tag">&lt;/<span class="name">enabled</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">snapshots</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">repository</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">repositories</span>&gt;</span></span><br><span class="line"></span><br><span class="line">  <span class="tag">&lt;<span class="name">pluginRepositories</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">pluginRepository</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">id</span>&gt;</span>central<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">name</span>&gt;</span>Central Repository<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">url</span>&gt;</span>https://repo.maven.apache.org/maven2<span class="tag">&lt;/<span class="name">url</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">layout</span>&gt;</span>default<span class="tag">&lt;/<span class="name">layout</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">snapshots</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">enabled</span>&gt;</span>false<span class="tag">&lt;/<span class="name">enabled</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">snapshots</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">releases</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">updatePolicy</span>&gt;</span>never<span class="tag">&lt;/<span class="name">updatePolicy</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">releases</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">pluginRepository</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">pluginRepositories</span>&gt;</span></span><br><span class="line"></span><br><span class="line">  <span class="tag">&lt;<span class="name">build</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">directory</span>&gt;</span>$&#123;project.basedir&#125;/target<span class="tag">&lt;/<span class="name">directory</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">outputDirectory</span>&gt;</span>$&#123;project.build.directory&#125;/classes<span class="tag">&lt;/<span class="name">outputDirectory</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">finalName</span>&gt;</span>$&#123;project.artifactId&#125;-$&#123;project.version&#125;<span class="tag">&lt;/<span class="name">finalName</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">testOutputDirectory</span>&gt;</span>$&#123;project.build.directory&#125;/test-classes<span class="tag">&lt;/<span class="name">testOutputDirectory</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">sourceDirectory</span>&gt;</span>$&#123;project.basedir&#125;/src/main/java<span class="tag">&lt;/<span class="name">sourceDirectory</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">scriptSourceDirectory</span>&gt;</span>$&#123;project.basedir&#125;/src/main/scripts<span class="tag">&lt;/<span class="name">scriptSourceDirectory</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">testSourceDirectory</span>&gt;</span>$&#123;project.basedir&#125;/src/test/java<span class="tag">&lt;/<span class="name">testSourceDirectory</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">resources</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">resource</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">directory</span>&gt;</span>$&#123;project.basedir&#125;/src/main/resources<span class="tag">&lt;/<span class="name">directory</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">resource</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">resources</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">testResources</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">testResource</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">directory</span>&gt;</span>$&#123;project.basedir&#125;/src/test/resources<span class="tag">&lt;/<span class="name">directory</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">testResource</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">testResources</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">pluginManagement</span>&gt;</span></span><br><span class="line">      <span class="comment">&lt;!-- <span class="doctag">NOTE:</span> These plugins will be removed from future versions of the super POM --&gt;</span></span><br><span class="line">      <span class="comment">&lt;!-- They are kept for the moment as they are very unlikely to conflict with lifecycle mappings (MNG-4453) --&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">plugins</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-antrun-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">version</span>&gt;</span>1.3<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-assembly-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">version</span>&gt;</span>2.2-beta-5<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-dependency-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">version</span>&gt;</span>2.8<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-release-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">version</span>&gt;</span>2.3.2<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">plugins</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">pluginManagement</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">build</span>&gt;</span></span><br><span class="line"></span><br><span class="line">  <span class="tag">&lt;<span class="name">reporting</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">outputDirectory</span>&gt;</span>$&#123;project.build.directory&#125;/site<span class="tag">&lt;/<span class="name">outputDirectory</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">reporting</span>&gt;</span></span><br><span class="line"></span><br><span class="line">  <span class="tag">&lt;<span class="name">profiles</span>&gt;</span></span><br><span class="line">    <span class="comment">&lt;!-- <span class="doctag">NOTE:</span> The release profile will be removed from future versions of the super POM --&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">profile</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">id</span>&gt;</span>release-profile<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line"></span><br><span class="line">      <span class="tag">&lt;<span class="name">activation</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">property</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">name</span>&gt;</span>performRelease<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">value</span>&gt;</span>true<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">activation</span>&gt;</span></span><br><span class="line"></span><br><span class="line">      <span class="tag">&lt;<span class="name">build</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">plugins</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">inherited</span>&gt;</span>true<span class="tag">&lt;/<span class="name">inherited</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-source-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">executions</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;<span class="name">execution</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">id</span>&gt;</span>attach-sources<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">goals</span>&gt;</span></span><br><span class="line">                  <span class="tag">&lt;<span class="name">goal</span>&gt;</span>jar<span class="tag">&lt;/<span class="name">goal</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;/<span class="name">goals</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;/<span class="name">execution</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">executions</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">inherited</span>&gt;</span>true<span class="tag">&lt;/<span class="name">inherited</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-javadoc-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">executions</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;<span class="name">execution</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">id</span>&gt;</span>attach-javadocs<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">goals</span>&gt;</span></span><br><span class="line">                  <span class="tag">&lt;<span class="name">goal</span>&gt;</span>jar<span class="tag">&lt;/<span class="name">goal</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;/<span class="name">goals</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;/<span class="name">execution</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">executions</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">inherited</span>&gt;</span>true<span class="tag">&lt;/<span class="name">inherited</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-deploy-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;<span class="name">updateReleaseInfo</span>&gt;</span>true<span class="tag">&lt;/<span class="name">updateReleaseInfo</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">plugins</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">build</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">profile</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">profiles</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">project</span>&gt;</span></span><br></pre></td></tr></table></figure>
      
    </div>

    

    
    
    

    

    

    
      <div>
        <ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>Tonny Yi</li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="http://codertang.com/2018/03/30/maven/" title="maven">http://codertang.com/2018/03/30/maven/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc/4.0/" rel="external nofollow" target="_blank">CC BY-NC 4.0</a> 许可协议。转载请注明出处！</li>
</ul>

      </div>
    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/maven/" rel="tag"># maven</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/03/08/linux-commands/" rel="next" title="Linux常用命令">
                <i class="fa fa-chevron-left"></i> Linux常用命令
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/04/17/JVM/" rel="prev" title="JVM知识整理">
                JVM知识整理 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/avatar.png" alt="Tonny Yi">
            
              <p class="site-author-name" itemprop="name">Tonny Yi</p>
              <p class="site-description motion-element" itemprop="description">Coding, Life, Zen</p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">49</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">42</span>
                    <span class="site-state-item-name">分类</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">59</span>
                    <span class="site-state-item-name">标签</span>
                  </a>
                </div>
              
            </nav>
          

          

          
            <div class="links-of-author motion-element">
              
                <span class="links-of-author-item">
                  <a href="https://github.com/tonnyyi" target="_blank" title="GitHub"><i class="fa fa-fw fa-github"></i>GitHub</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="mailto:tonnyemails@gmail.com" target="_blank" title="E-Mail"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  
                </span>
              
            </div>
          

          
          
            <div class="cc-license motion-element" itemprop="license">
              <a href="https://creativecommons.org/licenses/by-nc/4.0/" class="cc-opacity" target="_blank">
                <img src="/images/cc-by-nc.svg" alt="Creative Commons">
              </a>
            </div>
          

          
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#依赖示例"><span class="nav-number">1.</span> <span class="nav-text">依赖示例</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#坐标"><span class="nav-number">1.1.</span> <span class="nav-text">坐标</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#版本号"><span class="nav-number">1.2.</span> <span class="nav-text">版本号</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#依赖"><span class="nav-number">2.</span> <span class="nav-text">依赖</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#依赖范围"><span class="nav-number">2.1.</span> <span class="nav-text">依赖范围</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#传递性依赖"><span class="nav-number">2.2.</span> <span class="nav-text">传递性依赖</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#传递调解"><span class="nav-number">2.3.</span> <span class="nav-text">传递调解</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#可选依赖"><span class="nav-number">2.4.</span> <span class="nav-text">可选依赖</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#排除依赖"><span class="nav-number">2.5.</span> <span class="nav-text">排除依赖</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#归类依赖"><span class="nav-number">2.6.</span> <span class="nav-text">归类依赖</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#依赖查看"><span class="nav-number">2.7.</span> <span class="nav-text">依赖查看</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#生命周期"><span class="nav-number">3.</span> <span class="nav-text">生命周期</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#clean生命"><span class="nav-number">3.1.</span> <span class="nav-text">clean生命</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#default生命周期"><span class="nav-number">3.2.</span> <span class="nav-text">default生命周期</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#site生命周期"><span class="nav-number">3.3.</span> <span class="nav-text">site生命周期</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#命令行与生命周期关系"><span class="nav-number">3.4.</span> <span class="nav-text">命令行与生命周期关系</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#插件"><span class="nav-number">4.</span> <span class="nav-text">插件</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#插件目标-goal"><span class="nav-number">4.1.</span> <span class="nav-text">插件目标(goal)</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#内置绑定"><span class="nav-number">4.1.1.</span> <span class="nav-text">内置绑定</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#自定义绑定"><span class="nav-number">4.1.2.</span> <span class="nav-text">自定义绑定</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#插件配置"><span class="nav-number">4.2.</span> <span class="nav-text">插件配置</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#命令行中使用"><span class="nav-number">4.2.1.</span> <span class="nav-text">命令行中使用</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#pom中全局配置"><span class="nav-number">4.2.2.</span> <span class="nav-text">pom中全局配置</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#pom中插件任务配置"><span class="nav-number">4.2.3.</span> <span class="nav-text">pom中插件任务配置</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#插件解析"><span class="nav-number">4.3.</span> <span class="nav-text">插件解析</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#目标前缀解析"><span class="nav-number">4.3.1.</span> <span class="nav-text">目标前缀解析</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#仓库"><span class="nav-number">5.</span> <span class="nav-text">仓库</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#远程仓库认证"><span class="nav-number">5.1.</span> <span class="nav-text">远程仓库认证</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#从仓库解析依赖流程"><span class="nav-number">5.2.</span> <span class="nav-text">从仓库解析依赖流程</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#install"><span class="nav-number">5.3.</span> <span class="nav-text">install</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#超级pom"><span class="nav-number">6.</span> <span class="nav-text">超级pom</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#标准目录结构"><span class="nav-number">6.1.</span> <span class="nav-text">标准目录结构</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#archetype生成项目骨架"><span class="nav-number">6.2.</span> <span class="nav-text">archetype生成项目骨架</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#聚合与继承"><span class="nav-number">6.3.</span> <span class="nav-text">聚合与继承</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#可继承的pom元素"><span class="nav-number">6.3.1.</span> <span class="nav-text">可继承的pom元素</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#dependencyManagement"><span class="nav-number">6.3.2.</span> <span class="nav-text">dependencyManagement</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Maven属性"><span class="nav-number">6.4.</span> <span class="nav-text">Maven属性</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#setting-xml"><span class="nav-number">6.5.</span> <span class="nav-text">setting.xml</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#超级pom-1"><span class="nav-number">6.5.1.</span> <span class="nav-text">超级pom</span></a></li></ol></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2021</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Tonny Yi</span>

  

  
</div>


  <script src="https://unpkg.com/mermaid@7.1.2/dist/mermaid.min.js"></script>
  <script>
    if (window.mermaid) {
      mermaid.initialize("");
    }
  </script>





  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://theme-next.org">NexT.Mist</a></div>




        








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.3.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.3.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.3.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.3.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.3.0"></script>



  



	





  





  










  





  

  

  

  

  
  

  

  

  

  

  
  <style>
    .copy-btn {
      display: inline-block;
      padding: 6px 12px;
      font-size: 13px;
      font-weight: 700;
      line-height: 20px;
      color: #333;
      white-space: nowrap;
      vertical-align: middle;
      cursor: pointer;
      background-color: #eee;
      background-image: linear-gradient(#fcfcfc, #eee);
      border: 1px solid #d5d5d5;
      border-radius: 3px;
      user-select: none;
      outline: 0;
    }

    .highlight-wrap .copy-btn {
      transition: opacity .3s ease-in-out;
      opacity: 0;
      padding: 2px 6px;
      position: absolute;
      right: 4px;
      top: 8px;
    }

    .highlight-wrap:hover .copy-btn,
    .highlight-wrap .copy-btn:focus {
      opacity: 1
    }

    .highlight-wrap {
      position: relative;
    }
  </style>
  <script>
    $('.highlight').each(function (i, e) {
      var $wrap = $('<div>').addClass('highlight-wrap')
      $(e).after($wrap)
      $wrap.append($('<button>').addClass('copy-btn').append('复制').on('click', function (e) {
        var code = $(this).parent().find('.code').find('.line').map(function (i, e) {
          return $(e).text()
        }).toArray().join('\n')
        var ta = document.createElement('textarea')
        document.body.appendChild(ta)
        ta.style.position = 'absolute'
        ta.style.top = '0px'
        ta.style.left = '0px'
        ta.value = code
        ta.select()
        ta.focus()
        var result = document.execCommand('copy')
        document.body.removeChild(ta)
        
          if(result)$(this).text('复制成功')
          else $(this).text('复制失败')
        
        $(this).blur()
      })).on('mouseleave', function (e) {
        var $b = $(this).find('.copy-btn')
        setTimeout(function () {
          $b.text('复制')
        }, 300)
      }).append(e)
    })
  </script>


</body>
</html>
